var toFix = (val=>{
  let date = getDate();
  let day = date.getDate();
  if(val.substr(8,9) == day){
    return '今天'
  }else{
    return val.substr(5,9)
  }
})
var formDate = (val=>{
  let date = getDate(val)
  let y = date.getFullYear();
  let m = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1);
  let d = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
  return y + '-' + m +'-' + d
})

var formTime = (val=>{
  let date = getDate(val)
  let y = date.getFullYear();
  let m = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1);
  let d = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
  let h = date.getHours();
  let min = date.getMinutes();
  let s = date.getSeconds();
  let now = h*3600 + min*60 + s;
  let nowTime = parseInt(getDate().getTime()/1000);
  let overTime = nowTime - val/1000
  // let today = getDate(overTime);
  let hours = (date.getHours() > 9) ? date.getHours() : '0' + date.getHours();
  let minu  = (date.getMinutes() > 9) ? date.getMinutes() : '0' + date.getMinutes();
  if(overTime < 60){
    return overTime+ '秒前'
  }else if( overTime > 60 && overTime < 3600){
    return parseInt(overTime/60) + '分钟前'
  }else if(overTime > 3600 && overTime < now){
    return '今天'+ hours +':'+ minu
  }else if( overTime > 86400 && overTime < 31536000){
    return m +'-'+ d +' '+ hours +':'+ minu
  }
  // else{
  //   return y + '-' + m +'-' + d
  // }
})

var fixed = (val=>{
  let num1 = parseInt(val/100);
  return (num1/100).toFixed(2)
})
export default  {
  toFix: toFix,
  formDate:formDate,
  formTime:formTime,
  fixed:fixed
};